//
//  VideoObj.m
//  Brand
//
//  Created by Faker on 5/6/14.
//  Copyright (c) 2014 Faker. All rights reserved.
//

#import "VideoObj.h"

@implementation VideoObj

-(id)init{
    self = [super init];
    if (self) {
        self.hasPlayDur = 0.0;
        self.isLoading = NO;
        self.isComplete = NO;
        self.isInDownload = NO;
        self.percent = 0.0f;
        self.contentLength = 0;
        self.allowResume = YES;
        self.percentLast = 0;
    }
    return self;
}

#pragma mark - 序列化
//序列化，可以存储到本地的。
- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:self.contentId forKey:@"1"];
    [aCoder encodeObject:self.contentName forKey:@"2"];
    [aCoder encodeObject:self.episodeId forKey:@"3"];
    [aCoder encodeObject:self.episodeName forKey:@"4"];
    [aCoder encodeObject:self.type forKey:@"5"];
    [aCoder encodeObject:self.imageSrc forKey:@"9"];
    [aCoder encodeInt:self.currentPlayIndex forKey:@"12"];
    [aCoder encodeFloat:self.hasPlayDur forKey:@"13"];
    [aCoder encodeObject:self.playURL forKey:@"14"];
    
    [aCoder encodeBool:self.isLoading forKey:@"15"];
    [aCoder encodeBool:self.isComplete forKey:@"16"];
    [aCoder encodeFloat:self.percent forKey:@"17"];
    [aCoder encodeInt64:self.contentLength forKey:@"18"];
    [aCoder encodeBool:self.isInDownload forKey:@"19"];
    [aCoder encodeObject:self.downTaskResumeData forKey:@"20"];
    [aCoder encodeBool:self.allowResume forKey:@"21"];
    [aCoder encodeObject:self.requestTempFilePath forKey:@"22"];
    [aCoder encodeBool:self.isReadyShow forKey:@"23"];
    [aCoder encodeBool:self.isNeedVIP forKey:@"24"];
    
}

//反序列化，变成我们想要的。
- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];
    if (self){
        self.contentId = [aDecoder decodeObjectForKey:@"1"];
        self.contentName = [aDecoder decodeObjectForKey:@"2"];
        self.episodeId = [aDecoder decodeObjectForKey:@"3"];
        self.episodeName = [aDecoder decodeObjectForKey:@"4"];
        self.type = [aDecoder decodeObjectForKey:@"5"];
        self.imageSrc = [aDecoder decodeObjectForKey:@"9"];
        self.currentPlayIndex = [aDecoder decodeIntForKey:@"12"];
        self.hasPlayDur = [aDecoder decodeFloatForKey:@"13"];
        self.playURL = [aDecoder decodeObjectForKey:@"14"];
        
        self.isLoading = [aDecoder decodeBoolForKey:@"15"];
        self.isComplete = [aDecoder decodeBoolForKey:@"16"];
        self.percent = [aDecoder decodeFloatForKey:@"17"];
        self.contentLength = [aDecoder decodeInt64ForKey:@"18"];
        self.isInDownload = [aDecoder decodeBoolForKey:@"19"];
        self.downTaskResumeData = [aDecoder decodeObjectForKey:@"20"];
        self.allowResume = [aDecoder decodeBoolForKey:@"21"];
        self.requestTempFilePath = [aDecoder decodeObjectForKey:@"22"];
        self.isReadyShow = [aDecoder decodeBoolForKey:@"23"];
        self.isNeedVIP = [aDecoder decodeBoolForKey:@"24"];
    }
    return self;
}


@end
